//
//  PGoodsDetailsCell.m
//  wedding
//
//  Created by 常宽 on 15/1/28.
//  Copyright (c) 2015年 常宽. All rights reserved.
//

#import "PGoodsDetailsCell.h"
#import "GoodsDetailsModel.h" // 数据的model类

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define priceHeight 20

@interface PGoodsDetailsCell ()
/// 封面
@property (nonatomic, retain) UIImageView *myImageView;
/// 价格
@property (nonatomic, retain) UILabel *price;
@end

@implementation PGoodsDetailsCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.model = [[GoodsDetailsModel alloc] init];
        self.myImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.myImageView];
        
        self.price = [[UILabel alloc] init];
        [self.contentView addSubview:self.price];
        
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.myImageView.frame = CGRectMake(5, 5, WIDTH - 10, HEIGHT - 10 - priceHeight - 5);
    self.myImageView.clipsToBounds = YES;
    self.myImageView.layer.cornerRadius = 5;
    self.myImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.myImageView sd_setImageWithURL:[NSURL URLWithString:self.model.photo_path] placeholderImage:[UIImage imageNamed:@"NoPicture.jpg"]];
    
    self.price.frame = CGRectMake(5, 10 + self.myImageView.frame.size.height, WIDTH - 10, priceHeight);
    self.price.font = [UIFont boldSystemFontOfSize:25.f];
    self.price.textAlignment = NSTextAlignmentCenter;
    self.price.textColor = [WebColor lightCoral];
    self.price.text = [NSString stringWithFormat:@" ￥ %@  ", self.model.price];
    
}




/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
